<template>
  <!--卡位管理  查看短信的记录 -->
  <div class="app-container ">
    <div class="" v-loading="loading">
      <el-form :model="queryParams" ref="queryForm" :inline="true" class="zdy-form search-form-new" label-width="100px">
        <el-form-item label-width="70px" label="查看人" prop="createId">
        <el-select filterable clearable v-model="queryParams.createId" placeholder="请选择查看人">
          <el-option v-for="(item ,key) in yuangongList" :key="key" :label="item.nickName" :value="item.userId" />
        </el-select>
      </el-form-item>
        <el-form-item label="手机号码" prop="phone">
          <el-input placeholder="请输入手机号码" v-model="queryParams.phone" clearable></el-input>
        </el-form-item>
        <el-form-item label="时间" prop="timer">
          <el-date-picker v-model="timer" type="daterange" range-separator="至" value-format="yyyy-MM-dd" start-placeholder="开始日期" end-placeholder="结束日期" clearable>
          </el-date-picker>
        </el-form-item>
        <el-form-item class="btns">
          <el-button type="primary" icon="el-icon-search" @click="search" class="zdy-btn">搜索</el-button>
          <el-button type="warning" icon="el-icon-refresh" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
      <div class="tip">
        提示：关闭了短信内容展示后，查看短信需要手动点击，才会有短信查看记录。可前往“设置管理>参数配置>卡位短信设置”进行设置。
      </div>
      <div class="table_box table_box_new">
        <el-table border stripe :data="tableData.records">
          <!-- <el-table-column prop="id" label="序号" width="80"></el-table-column> -->
          <el-table-column prop="createTime" label="查看时间" width="160"></el-table-column>
          <el-table-column prop="createName" label="用户昵称" width="200"></el-table-column>
          <el-table-column prop="phone" label="卡位号码" width="120"></el-table-column>
          <el-table-column prop="fromNumber" label="发送方" width="180"></el-table-column>
          <el-table-column prop="content" label="短信内容" align="left" min-width="200" show-overflow-tooltip></el-table-column>
        </el-table>
        <pagination v-show="tableData.total > 0" :total="tableData.total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
      </div>
    </div>
 
  </div>
</template>

<script>
import phoneApi from "@/api/phoneManage";
import supplyConfigApi from "@/api/system/supplyConfig";
export default {
  name: "",
  // components: { addDialog },
  data() {
    return {
      timer: [],
      tableData: {
        records: [],
        total: 0,
      },
      loading: false,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        createId:'',
        phone:'',
        createTimeStart:'',
        createTimeEnd:''
      },
      yuangongList: [],
    };
  },
  created() {
    this.getList();
    this.getYuangongList()
  },
  activated() {},
  computed:{
    carrierTypes(){
      return this.$store.getters.gameYunyingshangList
    }
  },
  methods: {
    // 获取列表
    getList() {
      this.loading = true;
      if (this.timer && this.timer.length) {
        this.queryParams.createTimeStart = this.timer[0] + " 00:00:00";
        this.queryParams.createTimeEnd = this.timer[1] + " 23:59:59";
      } else {
        this.queryParams.createTimeStart = "";
        this.queryParams.createTimeEnd = "";
      }
      phoneApi.smsLookRec(this.queryParams).then((response) => {
        this.tableData.records = response.rows;
        this.tableData.total = response.total;
        this.loading = false;
      });
    },
    // 获取所有员工列表
    getYuangongList() {
      supplyConfigApi
        .getAllUserList({
          userNewType: 1,
        })
        .then((res) => {
          this.yuangongList = res.rows;
        });
    },
    copy(txt) {
      this.$copyText(txt).then((res) => {
        this.$message.success("已复制到剪切板");
      });
    },
    // 搜索
    search() {
      this.queryParams.pageNum = 1;
      this.getList();
    },

    //重置
    resetQuery() {
      this.resetForm('queryForm')
      this.timer = [];
      this.getList();
    },
  },
};
</script>
<style lang="scss" scoped>
.tip{
  margin-bottom: 10px;
  color: #999;
}

</style>